package org.sgmiller.quickstem.collections;

import org.sgmiller.quickstem.Stem;

/**
 * A transactional fixed-length one-dimensional array.
 * 
 */
public class TransactionalArray<E> {

	Stem<E>[] values;
	
	@SuppressWarnings("unchecked")
	public TransactionalArray(int size, E defValue) {
		values=new Stem[size];
		for (int i=0; i<size; i++) {
			values[i]=new Stem<E>(defValue);
		}
	}

	public TransactionalArray(int size) {
		this(size, null);
	}
	
	public E get(int idx) {
		return values[idx].get();
	}
	
	public void set(int idx, E value) {
		values[idx].set(value);
	}
}
